- /* sdfatans.cpp by K.Tsuru */
- // function ID = 3603 DARDIX
- /***************************************************************
- SDouble class
- inverse trigonometric function arctan x using series expansion
- arctan x = x - x^3/3 + x^5/5 -.... (|x|<1.0).
- Please use for a very small value |x|.
- See AsinSeries() for the meaning of "fe".
- Not default argument.
- *****************************************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- static const char* func = "AtanSeries";
- SDouble AtanSeries(const SDouble& x, int fe){
- if(x.NetRdxExp() > 0) x.SetError(x.OUT_OF_RANGE, func, 3603); // |x| > 1.0
-
- SDouble sum(x), xn(x), xsq(x*x), delta;
- ulong n = 1uL, mt = sum.SlOpMaxValue();
- sum.FixedPoint(fe);
-
- do{
- xn *= xsq;
- n += 2uL;
- if(n > mt){
- sum.SetError(sum.NOT_CONVERGE, func, -3603);
- break;
- }
- delta = DsDiv(xn, n);
- if(n & 2uL) sum -= delta; // n = 3, 7, 11, ...
- else sum += delta; // n = 5, 9, 13
- } while(delta.Sign(3603));
-
- sum.PointFree();
- sum.Reform(3603);
- sum.upToTerm = (n+1uL)/2uL;
-
- return sum;
- }
sdfatans.cpp : last modifiled at 2015/12/03 21:32:43(1,097 bytes)
created at 2017/10/07 10:22:50
The creation time of this html file is 2017/10/07 11:29:39 (Sat Oct 07 11:29:39 2017).